import type { Key, PageDTO, PageRes, SortDTO } from '@/types/global'
import type { AddComment, Comment, QueryComment, UpdateComment } from '@/types/comment'
import { request } from '@/utils/request'

export function queryCommentList(params: PageDTO & SortDTO & QueryComment) {
  return request.get<PageRes<Comment>>('/api/comment', { params })
}

export function addComment(data: AddComment) {
  return request.post('/api/comment', data)
}

export function getCommentById(id: number) {
  return request.get<Comment>('/api/comment/' + id)
}

export function updateComment(data: UpdateComment) {
  return request.put('/api/comment', data)
}

export function deleteCommentByIds(idList: Key[]) {
  return request.delete('/api/comment', {
    params: {
      idList: idList
    }
  })
}
